<?php
require_once ROOT_PATH.'include/cache/class_cache_factory.php';

function cache_get($key)
{
	if(!defined('MEMCACHE_ON') || !MEMCACHE_ON)return false;
	
	$cache = cacheFactory::getInstance();
	return $cache->get($key);
}

function cache_set($key, $data, $timeout='')
{
	if(!defined('MEMCACHE_ON') || !MEMCACHE_ON)return false;
	
	$cache = cacheFactory::getInstance();
	
	if(!$timeout)
	{
		$timeout = CACHE_TIMEOUT;
	}
	
	return $cache->set($key, $data, $timeout);
}

function cache_delete($key)
{
	if(!defined('MEMCACHE_ON') || !MEMCACHE_ON)return false;
	
	$cache = cacheFactory::getInstance();
	return $cache->delete($key);
}

function cache_clear()
{
	if(!defined('MEMCACHE_ON') || !MEMCACHE_ON)return false;
	
	$cache = cacheFactory::getInstance();
	return $cache->flush();
}